package com.bupt.ilink.controller;

import com.bupt.ilink.entity.pojo.TeamFlow.TeamFlowQueryRequest;
import com.bupt.ilink.entity.pojo.TeamFlow.UploadTeamFlowInfo;
import com.bupt.ilink.entity.pojo.store.QueryConditionInfo;
import com.bupt.ilink.entity.pojo.store.UploadFlowInfo;
import com.bupt.ilink.entity.store.Download;
import com.bupt.ilink.service.StoreService;
import com.bupt.ilink.service.TeamFlowService;
import com.bupt.ilink.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("TeamAPP")
public class TeamFlowController {

    @Autowired
    TeamFlowService teamFlowService;
    @Autowired
    StoreService storeService;

    @PostMapping("/components/upload")
    public R uploadFlow(@RequestBody UploadTeamFlowInfo teamFlowInfo) {
        return R.ok(teamFlowService.uploadTeamFlow(teamFlowInfo));
    }

    @PatchMapping("/components/update")
    public R updateFlow(@RequestBody UploadTeamFlowInfo teamFlowInfo) {
        return R.ok(teamFlowService.updateTeamFlow(teamFlowInfo));
    }


    @GetMapping("/components/query")
    public R getFlowsByCondition(QueryConditionInfo condition) {
        return R.ok(storeService.getFlowsByCondition(condition));
    }

    @GetMapping("/components/get")
    public R getFlowsByTeamCondition(TeamFlowQueryRequest query) {
        return R.ok(teamFlowService.getFlowsByTeamCondition(query));
    }

    @GetMapping("/components/download")
    public R getFlowsByTeamCondition(String flowId) {
        return R.ok(teamFlowService.downloadFlow(flowId));
    }

    @GetMapping("/tags")
    public R getTags() {
        return R.ok(teamFlowService.getTags());
    }

}
